package xyz.sicau.blog.service;

import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Service;
import xyz.sicau.blog.bean.Blog;
import xyz.sicau.blog.dao.BlogMapper;
import xyz.sicau.blog.dao.UserMapper;
import xyz.sicau.blog.utils.DiyMethod;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BlogService {
    @Resource
    BlogMapper blogMapper;
    @Resource
    DiyMethod diyMethod;

    @Resource
    UserMapper userMapper;

    /**
     * 查询多条博客（重载 getBlogs方法）
     */
    // 全部博客
    public String getBlogs(String username) {
        List<Blog> blogs = blogMapper.getBlogsByUsername(username);
        return JSON.toJSONString(blogs);
    }
    public String getBlogs(int userid) {
        List<Blog> blogs = blogMapper.getBlogsByUserid(userid);
        return JSON.toJSONString(blogs);
    }

}
